package com.globagames.jungleonline.view
{
	import com.globagames.jungleonline.model.JungleModelLocator;
	
	import kaaengine.objects.isometric.IsoObject;
	
	import mx.effects.Tween;
	import mx.effects.effectClasses.TweenEffectInstance;

	public class MyEffect extends TweenEffectInstance
	{
		private var modelJungle:JungleModelLocator = JungleModelLocator.getInstance();
		public function MyEffect(target:Object)
		{
			super(target);
		}
		// Define parameters for the effect.
        public var xFrom:Number;
        public var xTo:Number;
        public var isX:Boolean;
  
        // Override play() method class.
        override public function play():void {
            // All classes must call super.play().
            super.play();
            // Create a Tween object. The tween begins playing immediately.
            var tween:Tween = 
                createTween(this, xFrom, xTo, duration);  
                
        }

        // Override onTweenUpdate() method.
        override public function onTweenUpdate(val:Object):void {
        	if( isX) target.x = val;
        	else target.y = val;
        	modelJungle.om.placeObjectOnWorld(target as IsoObject,modelJungle.sm.world);
		    modelJungle.sm.render();
		    modelJungle.sm.invalidate();
        }
  
        // Override onTweenEnd() method.
        override public function onTweenEnd(val:Object):void {
            // All classes that implement onTweenEnd() 
            // must call    super.onTweenEnd().
            super.onTweenEnd(val);
        }

		
	}
}